<?php

namespace StudyBuddy\Controllers;


use StudyBuddy\Responder;
use StudyBuddy\Request;
use StudyBuddy\WebPage;

/**
 * This controller class is usually called
 * via ajax to get the quick registration form html
 *
 */
class Getchapter extends WebPage
{


	protected function main(){
                $e_maths = array(
                        1 => 'Factorisation',
                        2 => 'Numbers and four operations',
                        3 => 'Inequalities',
                        4 => 'Indices',
                        5 => 'Ratio, rate and proportion',
                        6 => 'Percentage',
                        7 => 'Speed',
                        8 => 'Algebra',
                        9 => 'Functions and graphs',
                        10 => 'Solutions of equations',
                        11 => 'Applied maths',
                        12 => 'Set language and notation',
                        13 => 'Matrices',
                        14 => 'Angles, triangles and polygons',
                        15 => 'Congruence and similarity',
                        16 => 'Properties of circles',
                        17 => 'Pythagoras\' theorem',
                        18 => 'Trigonometry',
                        19 => 'Mensuration',
                        20 => 'Coordinate geometry',
                        21 => 'Vectors',
                        22 => 'Data handling',
                        23 => 'Data analysis',
                        24 => 'Probability'
                );

                $a_maths = array(
                        1 => 'Quadratic equations and inequalities',
                        2 => 'Indices and surds',
                        3 => 'Polynomials',
                        4 => 'Simultaneous equations',
                        5 => 'Partial fractions',
                        6 => 'Binomial expansions',
                        7 => 'Exponential, logarithmic and modulus functions',
                        8 => 'Trigonometry',
                        9 => 'Coordinate geometry',
                        10 => 'Plane geometry',
                        11 => 'Differentiation',
                        12 => 'Integration'
                );

                $physics = array(
                        1 => 'Physical Quantities, Units and Measurements',
                        2 => 'Kinematics',
                        3 => 'Forces',
                        4 => 'Mass, Weight and Density',
                        5 => 'Moments',
                        6 => 'Work, Energy and Power',
                        7 => 'Pressure',
                        8 => 'Kinetic Model of Matter',
                        9 => 'Heat Capacity and Latent Heat',
                        10 => 'Transfer of Thermal Energy',
                        11 => 'Temperature',
                        12 => 'Thermal Properties of Matter',
                        13 => 'Waves',
                        14 => 'Sound',
                        15 => 'Reflection and Refraction',
                        16 => 'Lenses',
                        17 => 'Electromagnetic Spectrum',
                        18 => 'Current Electricity',
                        19 => 'Static Electricity',
                        20 => 'D.C. Circuits',
                        21 => 'Practical Electricity',
                        22 => 'Magnetism',
                        23 => 'Electromagnetism',
                        24 => 'Electromagnetic Induction',
                        25 => 'Transformers and C.R.O.'
                );

                $maths1 = array(
                    1 => 'Primes and Prime Factors',
                    2 => 'Real Numbers',
                    3 => 'Algebra',
                    4 => 'Solving equations and inequalities',
                    5 => 'Ratio, Rate and Percentage',
                    6 => 'Statistics',
                    7 => 'Cartesian Coordinates and Linear Functions',
                    8 => 'Angles and Geometrical Constructions',
                    9 => 'Triangles, Quadrilaterals and Polygons',
                    10 => 'Perimeter and Area of Plane Figures',
                    11 => 'Volume and Surface Area of Solids'
                );
                $science1 = array(
                    1 => 'Introducing Science',
                    2 => 'Scientific Inquiry',
                    3 => 'Basic Science Measurements',
                    4 => 'Speed and Density',
                    5 => 'Classifying Living Things',
                    6 => 'Classification of Matter',
                    7 => 'Elements, Compounds and Mixtures',
                    8 => 'Solutions and Suspensions',
                    9 => 'Particulate Model of Matter',
                    10 => 'Atoms, Molecules and Ions',
                    11 => 'Cells and Organisms',
                    12 => 'Movement of Substances',
                    13 => 'Transport in Living Things',
                    14 => 'Digestion',
                    15 => 'Sexual Reproduction in Human Beings',
                    16 => 'Issues on Sex'
                );
                $maths2 = array(
                    1 => 'Proportion',
                    2 => 'Geometry',
                    3 => 'Algebraic Expressions and Equations',
                    4 => 'Quadratic Expressions and Equations',
                    5 => 'Graphs',
                    6 => 'Pythagoras\' Theorem',
                    7 => 'Mensuration',
                    8 => 'Statistics',
                    9 => 'Sets, Probability'
                );
                $science2 = array(
                    1 => 'Energy Around Us',
                    2 => 'Photosynthesis and Respiration',
                    3 => 'Light and Colour',
                    4 => 'Introducing Electricity',
                    5 => 'Household Electricity',
                    6 => 'Force and Pressure',
                    7 => 'Forces at Work',
                    8 => 'Effects of Heat Energy',
                    9 => 'Transmission of Heat',
                    10 => 'Changing Matter',
                    11 => 'Living Things in an Ecosystem'
                );

		d('cp');
		
                $chapter = null;
                switch ($this->oRequest['s_id']) {
                    case 1:
                        $chapter = $e_maths;
                        break;
                    case 2:
                        $chapter = $a_maths;
                        break;
                    case 3:
                        $chapter = $physics;
                        break;

                    case 4:
                        $chapter = $maths1;
                        break;
                    case 5:
                        $chapter = $science1;
                        break;
                    case 6:
                        $chapter = $maths2;
                        break;
                    case 7:
                        $chapter = $science2;
                        break;
                    default:
                        break;
                }
                
                $current = '';
                $s = '
                    <select name="chapter" style="border:none; background:transparent; padding:0 3px 3px 0; width:86px; position:relative">
                        <option value="">Select Chapter</option>';
                
                
                $tpl = '<option value="%1$s"%2$s>%3$s</option>';
				if($chapter != null) {
					foreach($chapter as $key => $val){
							$selected = ($key == $current) ? ' selected="selected"' : '';
							$s .= vsprintf($tpl, array($key, $selected, $val));
					}
				}
                
                $s .= '
                    </select>
                    <span style="position:absolute; float:right; bottom:0; right:0; width:24px; height:24px; background-color:#ff8e33"></span>';
                
                
		$aChapter = array('chapter' => $s);

		Responder::sendJSON($aChapter);
	}
}